package com.rybbaby.tss.front.tssMemberPackage.dao.imp;

import com.rybbaby.tss.core.web.dao.imp.GenericDao;
import com.rybbaby.tss.front.tssMemberPackage.dao.ITssMemberPackageDao;
import com.rybbaby.tss.front.tssMemberPackage.dao.ViewMemberPackageStudentDao;
import com.rybbaby.tss.front.tssMemberPackage.entity.TssMemberPackage;
import com.rybbaby.tss.front.tssMemberPackage.entity.ViewMemberPackageStudent;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @description 会员课时包信息视图操作实现
 * 
 * @author 杨然
 * 
 * @createDate 2017年11月7日10:03:46
 */
@Repository
public class ViewMemberPackageStudentDaoImp extends GenericDao<ViewMemberPackageStudent> implements ViewMemberPackageStudentDao {

    /**
     * 无条件查询所有数据
     * */
    @Override
    public List<ViewMemberPackageStudent> getAllList() {
        return super.loadAll(ViewMemberPackageStudent.class);
    }

    /**
     * 根据ids查询该集合
     * */
    @Override
    public List<ViewMemberPackageStudent> findListByStuId(List<String> stuIds) {
        return super.loadByMultipleId(ViewMemberPackageStudent.class, stuIds);
    }

    @Override
    public List<ViewMemberPackageStudent> findListByCondition(String stuPhone, String stuName) throws Exception {
       String sql = "SELECT\n" +
               "\t*\n" +
               "FROM\n" +
               "\tview_memberPackage_student_staff a\n" +
               "WHERE\n" +
               "a.stuPhone LIKE '%" + stuPhone + "%'";
        return this.findListBySql(sql, ViewMemberPackageStudent.class, null);
    }

    @Override
    public List<ViewMemberPackageStudent> findListByType(Integer type) {
        String hql = "from ViewMemberPackageStudent as a where a.type="+type;
        return super.findByHql(hql);
    }

    @Override
    public List<ViewMemberPackageStudent> findListByStatus(Integer stuStatus) {
        String hql = "";
        if(stuStatus == null){
            hql = "from ViewMemberPackageStudent a where a.stuStatus is not null and a.type = 1";
        } else{
            hql = "from ViewMemberPackageStudent a where a.stuStatus is not null and a.type = 2";
        }
        return findByHql(hql);
    }
}
